//
// Created by 86176 on 2021/11/24.
//

#include <iostream>
#include <stdlib.h>
#include "MydeCodeFilterChain1.h"
#include "MyMessage.h"

Message *MydeCodeFilterChain1::deCode(Session *pSession, IoBuffer *ioBuffer) {
    MyMessage *message = new MyMessage();
    if(ioBuffer->getBufferLen() <= message->headLen)
        return NULL;
    ioBuffer->filp();
//    message->packLen = ioBuffer->getInt();
//    message->flag = ioBuffer->getByte();


    ioBuffer->getBuffer((BYTE*)message->idFrom,10);
    ioBuffer->getBuffer((BYTE*)message->idTo,10);
    ioBuffer->getBuffer((BYTE*)message->keep,3);
    message->type = ioBuffer->getByte();
    //    ioBuffer->getBuffer((BYTE*)message->len,2);
    //    unsigned short length; //4

    //    ioBuffer->getString(22);
    //    unsigned short len;
    //    message->packLen ;
    message->length = ioBuffer->getShort();
    message->contect = ioBuffer->getString(pSession->packetLen - 2 - message->headLen);
    ioBuffer->compact();
    return message;
}

Message *MydeCodeFilterChain1::enCode(Session *pSession, IoBuffer *ioBuffer) {
    //todo 解码具体工作，包->iobuffter
    return nullptr;
}
